using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class TipsControl : MonoBehaviour
{
    private const string textPath = "Textures/Text/";
    private const string soundPath = "Sounds/";
    private static class Name
    {
        public static string fantasticTextName = "fantastic_text";
        public static string goodTextName = "good_text";
        public static string greatTextName = "great_text";
        public static string noMoreMatchTextName = "no_match_text";

        public static string fantasticSoundName = "fantastic";
        public static string goodSoundName = "good";
        public static string greatSoundName = "great";
        public static string noMoreMatchSoundName = "no_more_match";

    }
    public enum TipType
    {
        fantastic,
        good,
        great,
        noMoreMatch,
    }
    public Image image;
    public Animator anim;
    public AudioSource audioSource;
    public void LoadName(string textName,string soundName)
    {
        gameObject.SetActive(true);
        LoadManager.Instance.LoadAsync<Sprite>(textPath + textName, (obj) => { image.sprite = obj;});
        LoadManager.Instance.LoadAsync<AudioClip>(soundPath + soundName, (obj) => { audioSource.clip = obj;audioSource.Play();});
    }
    public void Play(TipType type)
    {
        gameObject.SetActive(false);
        
        string textName = "", soundName = "";
        switch (type)
        {
            case TipType.fantastic:
                {
                    textName = Name.fantasticTextName;
                    soundName = Name.fantasticSoundName;
                    break;
                }
            case TipType.good:
                {
                    textName = Name.goodTextName;
                    soundName = Name.goodSoundName;
                    break;
                }
            case TipType.great:
                {
                    textName = Name.greatTextName;
                    soundName = Name.greatSoundName;
                    break;
                }
            case TipType.noMoreMatch:
                {
                    textName = Name.noMoreMatchTextName;
                    soundName = Name.noMoreMatchSoundName;
                    break;
                }
        }
        LoadName(textName,soundName);
        anim.Play("play");

    }
    public void End()
    {
        gameObject.SetActive(false);
        
    }
    public void test()
    {
        Debug.Log("start");
    }

}
